home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Carnage_Contest / scripts / CC Original / tools / Super Shaft.lua < prev    next >
Text File  |  2010-08-09  |  2KB  |  76 lines

  1. --------------------------------------------------------------------------------
  2. -- Super Shaft by Holzchopf
  3. --------------------------------------------------------------------------------
  4.  
  5. -- setup
  6. if cc==nil then cc={} end
  7. cc.supershaft={}
  8.  
  9. -- load ressources
  10. cc.supershaft.gfx_icn=loadgfx("weapons/supershaft.png")                                -- Weapon Image
  11. setmidhandle(cc.supershaft.gfx_icn)
  12. cc.supershaft.gfx_wpn=loadgfx("buildings/shaftpart.png")                            -- Weapon Image
  13. setmidhandle(cc.supershaft.gfx_wpn)
  14. cc.supershaft.sfx_build=loadsfx("crumble.ogg")
  15.  
  16. --------------------------------------------------------------------------------
  17. -- Weapon
  18. --------------------------------------------------------------------------------
  19. cc.supershaft.id=addweapon("cc.supershaft","Super Shaft",cc.supershaft.gfx_icn,0)
  20. cc.supershaft.ammo=1000
  21.  
  22. function cc.supershaft.draw()                                                -- Draw
  23.     -- HUD Positioning
  24.     if weapon_shots==0 then
  25.         hudpositioning(pos_build,cc.supershaft.gfx_wpn,100,0,1)
  26.     end
  27. end
  28.  
  29. function cc.supershaft.attack(attack)
  30.     -- start
  31.     if (weapon_mode==0) and (weapon_position==1) then
  32.         if weapon_x>getplayerx(0) then
  33.             weapon_mode=1
  34.         else
  35.             weapon_mode=-1
  36.         end
  37.         -- No more weapon switching!
  38.         useweapon(0)
  39.         -- Make sure that there is enough round time
  40.         secondsleft=math.floor(getframesleft()/50)
  41.         changeturntime(30-secondsleft)
  42.     end
  43.     -- Build (auto!)
  44.     if weapon_mode~=0 then
  45.         if weapon_timer>=10 then
  46.             weapon_timer=0
  47.             weapon_shots=weapon_shots+1
  48.         end
  49.         -- end if necessary
  50.         if (weapon_shots>=cc.supershaft.ammo) then
  51.             endturn()
  52.         else
  53.             -- place shaft part
  54.             if weapon_timer==0 then
  55.                 -- check place
  56.                 if collision(cc.supershaft.gfx_wpn,weapon_x,weapon_y,0,1)==0 and collision(cc.supershaft.gfx_wpn,weapon_x,weapon_y,1,0)==1 and weapon_x>0 and weapon_x<getmapwidth() then
  57.                     scroll(weapon_x,weapon_y)
  58.                     -- draw
  59.                     terrainalphaimage(cc.supershaft.gfx_wpn,weapon_x,weapon_y)
  60.                     -- effect
  61.                     playsound(cc.supershaft.sfx_build)
  62.                     for i=1,10,1 do
  63.                         particle(p_fragment,weapon_x+math.random(-15,15),weapon_y+math.random(-12,12))
  64.                     end
  65.                 else
  66.                     weapon_shots=cc.supershaft.ammo
  67.                 end
  68.             end
  69.             -- draw
  70.             terrainrect(weapon_x-2-13*weapon_mode,weapon_y-13,3,25,0x00000000)
  71.             -- move
  72.             weapon_x=weapon_x+3*weapon_mode
  73.             weapon_timer=weapon_timer+1
  74.         end
  75.     end
  76. end